package com.sc.service.impl.patrol;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.patrol.PatrolTask;
import com.sc.dto.PatrolTaskDTO;
import com.sc.mapper.patrol.PatrolTaskMapper;
import com.sc.result.PageResult;
import com.sc.service.patrol.PatrolTaskService;
import com.sc.vo.PatrolTaskVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 巡检任务
 * @author: Zuiliu
 * 添加服务层实现类
 **/
@Service
public class PatrolTaskServiceImpl extends ServiceImpl<PatrolTaskMapper, PatrolTask> implements PatrolTaskService {

    @Override
    public PageResult<PatrolTaskVO> listPatrolTask(PatrolTaskDTO patrolTaskDTO) {
        int start = (patrolTaskDTO.getPageNum() - 1) * patrolTaskDTO.getPageSize();
        int end = patrolTaskDTO.getPageNum() * patrolTaskDTO.getPageSize();

        List<PatrolTaskVO> patrolTaskVOList = baseMapper.pageQuery(patrolTaskDTO);
        PageResult<PatrolTaskVO> page = new PageResult<>(patrolTaskVOList.size(), patrolTaskVOList.subList(start, Math.min(patrolTaskVOList.size(), end)));
        return page;
    }
}
